/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package torrent;

/**
 *
 * @author THIEUQUANG
 */
public class Controller extends Function implements Runnable {

    int chunk;
    String filename;

    public Controller(String filename, int chunk) {
        this.filename = filename;
        this.chunk = chunk;
    }

    @Override
    public void run() {

        Thread brrecv = new Thread(new broadcastreceiver());// mac dinh mo khi khoi dong
        brrecv.start();
        if (!filename.equals("")) {
            Thread br = new Thread(new broadcastsender(filename + " " + Integer.toString(chunk) + " CHK ."));
            br.start();
        }

        Thread t = new Thread(this);
        t.interrupt();
    }

    synchronized void mysuspend() {
        try {
            this.wait();
        } catch (InterruptedException e) {
        }
    }
}
